<template>
  <view class="home_top">
    <view class="content">
			<view class="item" v-for="(item,index) in topList" :key="index" @click="handleClick(item)">
				<view class="img">
					<image :src="item.img" mode="widthFix"></image>
				</view>
				<text>{{item.text}}</text>
			</view>
		</view>
  </view>
</template>

<script>
import { gethexiao } from '@/request/api.js'
import { toast,useRouter } from '@/request/utils.js'
export default {
  data() {
    return {
      topList: [
        {
          img: "https://hetp.hephp.cn/static/images/home_sm.png",
					text: '扫码验券',
					path: '',
					type: '1',
        },
				{
				  img: "https://hetp.hephp.cn/static/images/home_kz.png",
					text: '客资',
					path: '/pagesA/kzCenter/kzCenter'
				},
				{
				  img: "https://hetp.hephp.cn/static/images/home_tk.png",
					text: '退款',
					path: '/pagesA/order/order'
				},
      ],
    };
  },
	methods: {
		handleClick(item){
			let that = this
			console.log(item)
			if(item.type){
				uni.scanCode({
				  onlyFromCamera: false,
				  success (res) {
					console.log("扫描内容",res.result)
					console.log("rawData",res.rawData)
					that.getOrders(res.result)
				  }
				})
			}else{
				this.goToPage(item.path);
			}
		},
		//核销处理
		async getOrders(nums) {
			console.log('测试传输',nums)
		  let res = await gethexiao({nums:nums});
		  if(res.code==200){
			  this.goToNoLoginPage('/pagesA/orderDetailHX/orderDetailHX?id='+res.data.couponId,'navigateTo');
		  }else{
			  toast(res.message)
		  }
		},
	}
};
</script>

<style lang="scss" scoped>
.content {
  display: flex;
  justify-content: space-between;
  align-items: center;
	padding: 20rpx 0;
	background-color: #fff;
	border-radius: 14rpx;
	.item {
		width: 30%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #3D3D3D;
		line-height: 45rpx;
		font-size: 29rpx;
		.img {
			width: 40rpx;
			height: 40rpx;
			margin-bottom: 10rpx;
		}
	}
}
</style>
